package cn.bingoogolapple.qrcode.zxingdemo;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * Created by Administrator on 2017/5/14 0014.
 */

public class WebViewAc extends Activity {
    private WebView webView;
    private String uri;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.weview);
        uri=getIntent().getStringExtra("url");
        init();
    }
    private void init(){
        webView = (WebView) findViewById(R.id.wb);
        //WebView加载web资源
      //  webView.loadUrl("http://baidu.com");
        webView.loadUrl(uri);
        //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为，使网页用WebView打开
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                //返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
                view.loadUrl(url);
                return true;
            }
        });
    }
}
